package com.itaem.community.modules.infrastructure.company.company.mapper;

import com.itaem.community.modules.infrastructure.company.company.dto.CompanyBriefDTO;
import com.itaem.community.modules.infrastructure.company.company.dto.CompanyCreateDTO;
import com.itaem.community.modules.infrastructure.company.company.dto.CompanyDTO;
import com.itaem.community.modules.infrastructure.company.company.dto.CompanyUpdateDTO;
import com.itaem.community.modules.infrastructure.company.company.entity.PropertyManagementCompanyEntity;
import com.itaem.community.modules.infrastructure.company.department.dto.DepartmentBriefDTO;
import com.itaem.community.modules.infrastructure.company.department.dto.DepartmentDTO;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>项目名称: community </p>
 * <p>文件名称: CompanyTransformer </p>
 * <p>描述: [类型描述] </p>
 * <p>创建时间: 2020/10/31 </p>
 * <p>作者信息: tomato</p>
 *
 * @author tomato
 * @version v1.0
 */
@Mapper(componentModel = "spring")
public interface CompanyTransformer {

    /**
     * 提取要新增的信息到数据库实体类中
     *
     * @param createDto 要新增的信息
     * @return 数据库实体
     */
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "deleted", expression = "java(Boolean.FALSE)")
    PropertyManagementCompanyEntity createDtoToEntity(CompanyCreateDTO createDto);

    /**
     * 提取要更新的信息到数据库实体类中
     *
     * @param updateDto 要更新的信息
     * @return 数据库实体类
     */
    @Mapping(target = "deleted", expression = "java(Boolean.FALSE)")
    PropertyManagementCompanyEntity updateDtoToEntity(CompanyUpdateDTO updateDto);

    /**
     * 提取数据库信息到数据传输对象中
     *
     * @param entity      数据库实体信息
     * @param departments 物业公司下的部门信息
     * @return 数据传输对象
     */
    CompanyDTO entityToDto(PropertyManagementCompanyEntity entity, List<DepartmentBriefDTO> departments);

    /**
     * 提取要数据库信息到（简要）数据传输对象中，用于分页数据展示
     *
     * @param entity 数据库实体信息
     * @return 分页数据传输对象
     */
    CompanyBriefDTO entityToBriefDto(PropertyManagementCompanyEntity entity);
}
